package com.raycloud.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.raycloud.dao.MsgDao;
import com.raycloud.dao.common.BaseDao;
import com.raycloud.domain.Msg;

public class MsgDaoImpl extends BaseDao implements MsgDao{

	public void insertMsg(Msg msg) {
		getSqlMapClientTemplate().insert("msg.insertMsg", msg);
	}

	@SuppressWarnings("unchecked")
	public List<Msg> queryMsgWidthIds(List<String> msgIds) {
		return getSqlMapClientTemplate().queryForList("msg.queryMsgWidthIds", msgIds);
	}

	public void updateCount(int offset, String msgId, String type) {
		Map<String, Object> codition = new HashMap<String, Object>();
		codition.put("offset", offset);
		codition.put("msgId", msgId);
		codition.put("type", type);
		getSqlMapClientTemplate().update("msg.updateCountByType", codition);
	}

	public Msg getMsgById(String msgId) {
		Map<String, Object> codition = new HashMap<String, Object>();
		codition.put("msgId", msgId);
		return (Msg) getSqlMapClientTemplate().queryForObject("msg.getMsgById", codition);
	}

	@SuppressWarnings("unchecked")
	public List<Msg> queryMsgWidthReferenceMsgId(List<String> reMsgIds,
			String msgRelationDbId) {
		Map<String, Object> codition = new HashMap<String, Object>();
		codition.put("reMsgIds", reMsgIds);
		codition.put("dbId", msgRelationDbId);
		return getSqlMapClientTemplate().queryForList("msg.queryMsgWidthReferenceMsgId", codition);
	}

	public Msg getMsgWidthWidthReferenceMsgId(String msgId,
			String msgRelationDbId) {
		Map<String, Object> codition = new HashMap<String, Object>();
		codition.put("msgId", msgId);
		codition.put("dbId", msgRelationDbId);
		return (Msg) getSqlMapClientTemplate().queryForObject("msg.getMsgWidthWidthReferenceMsgId", codition);
	}

	
}
